package com.goodluck.goodluckim.ui.msg.adapter;


import com.chad.library.adapter.base.BaseViewHolder;
import com.chad.library.adapter.base.MultipleItemRvAdapter;
import com.goodluck.goodluckim.db.model.IMMessage;
import com.goodluck.goodluckim.sdk.msg.MsgViewHolderFactory;
import com.goodluck.goodluckim.ui.msg.viewholder.DefaultMsgViewHolderFactory;

import java.util.List;

/**
 * Created by wyj on 2018/9/10.
 */
public class MessageAdapter extends MultipleItemRvAdapter<IMMessage, BaseViewHolder> {


    private MsgViewHolderFactory msgViewHolderFactory;

    public void setMsgViewHolderFactory(DefaultMsgViewHolderFactory msgViewHolderFactory) {
        this.msgViewHolderFactory = msgViewHolderFactory;
    }

    public MessageAdapter(List<IMMessage> data) {
        super(data);
        msgViewHolderFactory = new DefaultMsgViewHolderFactory();
        finishInitialize();
    }

    @Override
    protected int getViewType(IMMessage message) {
        return msgViewHolderFactory.getViewType(message);
    }

    @Override
    public void onBindViewHolder(BaseViewHolder holder, int position, List<Object> payloads) {
        super.onBindViewHolder(holder, position, payloads);
    }

    @Override
    public void registerItemProvider() {
        msgViewHolderFactory.registerProviders(mProviderDelegate);
    }
}
